<template>
	<view class="page padding-lr">
		<view class="content">
			<jyf-parser :html="body"></jyf-parser>
		</view>
		<view class="agreement" v-if="body">
			<image class="image" @click="handle_select" v-if="is_select_agree" src="../../../user/static/checked.png">
			</image>
			<image class="image" @click="handle_select" v-else src="../../../user/static/unchecked.png"></image>
			<view><text>我已阅读并同意以上协议</text></view>
		</view>
		<view class="login-btn" @click="handleNext" v-if="body">
			下一步，填写申请信息
		</view>
		<!-- 断网监测 start -->
		<fu-notwork></fu-notwork>
		<!-- 断网监测 end -->

	</view>
</template>

<script>
	import richText from "@/common/utils/richText.js";
	export default {
		data() {
			return {
				body: '',
				is_select_agree: false
			};
		},
		onLoad() {
			this.getShopAgreement();
		},
		methods: {
			/**
			 * @param 是否选择同意协议
			 */
			handle_select() {
				this.is_select_agree = !this.is_select_agree
			},
			handleNext() {
				if (!this.is_select_agree) return this.$message.info('请阅读并同意以上协议');
				uni.navigateTo({
					url: '/pages/user/shop/shop-package/index'
				})
			},
			getShopAgreement() {
				this.$api
					.post('/v1/61035da523cd1')
					.then(res => {
						console.log(res);
						if (res.data.code == 1) {
							this.body = richText.format(res.data.data.content);
						} else {
							this.$message.info(res.data.msg);
						}
					})
					.catch(err => {
						console.log(err);
					});
			}
		}
	};
</script>

<style scoped lang="scss">
	page {
		height: 100%;
		background: #ffffff;
	}

	.page {
		padding-bottom: calc(60rpx + constant(safe-area-inset-bottom));
		padding-bottom: calc(60rpx + env(safe-area-inset-bottom));
	}

	.content {
		min-height: 800rpx;
	}

	.agreement {
		display: flex;
		width: 100%;
		font-family: PingFangSC-Regular;
		font-size: 28rpx;
		color: #666666;
		align-items: center;
		justify-content: center;
		margin: 30rpx 0;

		.image {
			height: 28rpx;
			width: 28rpx;
			margin-right: 12rpx;
		}

		text {
			color: #999999;
		}
	}

	.login-btn {
		height: 88rpx;
		line-height: 88rpx;
		background: $bgtheme;
		opacity: 1;
		border-radius: 44rpx;
		margin: 30rpx 0rpx;
		font-size: 32rpx;
		color: #FFFFFF;
		font-family: PingFang SC;
		font-weight: 500;
		text-align: center;
	}
</style>
